/**
 * @param {HTMLElement} el
 * @returns {Object}
 */
export function getElementPosition(el: HTMLElement): { top: number; left: number } {
  if (!el) return { top: 0, left: 0 }
  try {
    const rect = el.getBoundingClientRect()
    return {
      top: rect.top + window.pageYOffset,
      left: rect.left + window.pageXOffset
    }
  } catch (e) {
    return { top: 0, left: 0 }
  }
} 